package org.dylan.web.model;

public class JsonResult<T> {
	public T data;//附带的额外数据
	private boolean success = true;
	private String msg;

	public JsonResult() {
	}

	public JsonResult(boolean success) {
		this.success = success;
	}

	public JsonResult(T data) {
		this.data = data;
	}

	/**
	 * @param success
	 * @param msg
	 */
	public JsonResult(boolean success, T data) {
		super();
		this.success = success;
		this.data = data;
	}

	public static StrJsonResult str() {
		return new StrJsonResult();
	}

	public static StrJsonResult str(String msg) {
		return new StrJsonResult(msg);
	}

	public static StrJsonResult str(boolean success, String msg) {
		return new StrJsonResult(success, msg);
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

	public boolean isSuccess() {
		return success;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}


	public static class StrJsonResult extends JsonResult<String> {
		public StrJsonResult() {
		}

		public StrJsonResult(boolean success) {
			super(success);
		}

		public StrJsonResult(String data) {
			super(data);
		}

		/**
		 * @param success
		 * @param data
		 */
		public StrJsonResult(boolean success, String data) {
			super(success, data);
		}

	}
}
